<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="file" name="file1"  id="file1"/>
    <button id = "btn">提交</button>
</body>
<script>
    var btn = document.getElementById('btn')
    var file1 = document.getElementById('file1')
    btn.onclick = function(){
        var formData = new FormData
        formData.append("myimg",file1.files[0])
        fetch("http://localhost:8081/upload",{
            method:"PUT",
            body:formData
        })
        //第一个then声明数据类型；text()：纯文本；json():json数据
        .then(res=>{
            return res.text()
        }).then(res=>{
            console.log(res)
        })
    }
</script>
</html>